<template>
  <!-- <div
    :title="dialogTittle"
    :visible.sync="dialogFormVisible"
    @opened="opened()"
    @open="open"
    :destroy-on-close="true"
    style="margin-top: -10vh;"
    width="1500px"
  > -->
    <div style="border:0px solid red;width:100%;height: 250PX;margin-bottom: 70PX;;">
      <routeChart ref="timeDistanceChart"
        :greenWaveParam="greenWaveParam"
        @showResetChart="showResetChart"
        :isShowPlanChart="isShowPlanChart"
        :isShowRealtimeChart="isShowRealtimeChart"
        :isShowTitle="isShowTitle"
        ></routeChart>
    </div>
  <!-- </div> -->
</template>

<script>
/* eslint-disable */
import routeChart from '../../../RouteOptimize/pattern/planChart/index.vue'
export default {
  name: "TimeDistanceChart",
  components: {routeChart },
  props: {
    isShowPlanChart: {
      type: Boolean,
      default: true
    },
    isShowRealtimeChart: {
      type: Boolean,
      default: true
    },
    isShowTitle: {
      type: Boolean,
      default: true
    },
    isShowOperation: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      direction: 'all',
      directionRealtime: 'all',
      greenWaveParam: [],
      chartData: {},
      dialogTittle: '',
      dialogFormVisible: false,
      model: {},
      list: []
    };
  },
  methods: {
    open () {
      this.direction = 'all'
      this.directionRealtime = 'all'
    },
    opened () {
      let {
        routeData,
        realPatternRouteData,
        patternList,
        greenwave,
        allPatternList
      } = {...this.chartData}
      let routeChart = this.$refs.timeDistanceChart
      if (this.isShowRealtimeChart) {
        let realPatternRouteDataCopy = JSON.parse(JSON.stringify(realPatternRouteData))
        realPatternRouteDataCopy.direction = this.directionRealtime
        routeChart.onRealtimeChart (realPatternRouteDataCopy, allPatternList, greenwave, this.devicesData)
      }
      if (this.isShowPlanChart) {
        let routeDataCopy = JSON.parse(JSON.stringify(routeData))
        routeDataCopy.direction = this.direction
        routeChart.onPlanChart (routeDataCopy, patternList, greenwave, this.devicesData)
      }
    },
    showResetChart (direction, directionRealtime) {
      this.direction = direction
      this.directionRealtime = directionRealtime
      this.opened()
    },
    show (bShow = true, chartData, routeName, devicesData, greenWaveParam) {
      this.dialogFormVisible = bShow
      this.chartData = chartData
      this.devicesData = devicesData
      this.dialogTittle = routeName
      //  + ' ' + this.$t('openatc.greenwaveoptimize.spaceGraph')
      this.greenWaveParam = greenWaveParam
      this.open()
      this.opened()
    }
  }
};
</script>


<style lang="scss" rel="stylesheet/scss">
.el-dialog__title {
  font-weight: bold;
}
</style>
